package com.norriekoelle.virtualsensors.server;

/**
 * Commands recognised from the Kinect that may be handled by the app. 
 * 
 * Feed server message into here and switch over result for commands interested in.
 * 
 * @author Lauren Norrie (norrielm)
 */
// TODO(norrielm): Tidy this up.
public class CommandInterface {

	public static enum commands { 
		HOTSPOT, HOTSPOT_OFF,
		TRACKING_ON, TRACKING_OFF, LOST_USER, NEW_USER,
		SWIPE_UP, SWIPE_DOWN, SWIPE_L, SWIPE_R,
		PUSH,RAISE_HAND,CIRCLE,WAVE,SELECT,CLICK,
		LOG_ON, LOG_OFF,
		ACK, CONNECT, EXIT, 
		UNDEFINED}; 
	
	public static CommandInterface.commands handleKinectMessage(String s) {
		s = s.toLowerCase();
		
    	if (s == null || s.contains("exit")) {
    		return CommandInterface.commands.EXIT;
    	} else if(s.contains("ack")) {
			return CommandInterface.commands.ACK;	
    	} else if(s.contains("connect")) {
    		return CommandInterface.commands.CONNECT;
    	} else if (s.contains("accel") && s.contains("on")) {
			return CommandInterface.commands.TRACKING_ON;
    	} else if (s.contains("accel") && s.contains("off")) {
			return CommandInterface.commands.TRACKING_OFF;
    	} else if(s.contains("user") && s.contains("new")) {
			return CommandInterface.commands.NEW_USER;
    	} else if(s.contains("user") && s.contains("lost")) {
			return CommandInterface.commands.LOST_USER;
    	} else if(s.contains("log") && s.contains("on")) {
			return CommandInterface.commands.LOG_ON;
    	} else if(s.contains("log") && s.contains("off")) {
			return CommandInterface.commands.LOG_OFF;
    	} else if(s.contains("hotspot") && s.contains ("on")) {
    		return CommandInterface.commands.HOTSPOT;
    	} else if(s.contains("hotspot") && s.contains ("off")) {
    		return CommandInterface.commands.HOTSPOT_OFF;
    	} else if(s.contains("swipe") && (s.contains("up"))) {
    		return CommandInterface.commands.SWIPE_UP;
    	} else if(s.contains("swipe") && (s.contains("down"))) {
    		return CommandInterface.commands.SWIPE_DOWN;
    	} else if(s.contains("swipe") && (s.contains("left"))) {
    		return CommandInterface.commands.SWIPE_L;
    	} else if(s.contains("swipe") && (s.contains("right"))) {
    		return CommandInterface.commands.SWIPE_R;
    	} else if(s.contains("push")) {
    		return CommandInterface.commands.PUSH;
    	} else if(s.contains("raise") && (s.contains("hand"))) {
    		return CommandInterface.commands.RAISE_HAND;	
    	} else if(s.contains("circle")) {
    		return CommandInterface.commands.CIRCLE;
    	} else if(s.contains("wave")) {
    		return CommandInterface.commands.WAVE;
    	} else if(s.contains("select")) {
    		return CommandInterface.commands.SELECT;
    	} else {
    		return commands.UNDEFINED;
    	}
	}	
}
